<template>
	<view class="content" v-if="data">
		<view class="banner">
			<image :src="this.data.thumb" mode="aspectFill"></image>
			<view class="mask">{{this.data.name}}</view>
		</view>
		<view class="index_section">
			<uni-section :title="clients.name">
				<template v-slot:decoration>
					<view class="decoration"></view>
				</template>
				<template v-slot:right>
					<image class="v-slot-image" src="/static/builder_simple1.png"></image>
				</template>
				<view class="item_column" v-for="(item,index) in clients.listContent" :key="index">
					<view class="item_name">
						{{item.name}}
					</view>
					<view class="item_content">
						{{item.content}}
					</view>
				</view>
			</uni-section>
			<uni-section :title="location" @click="onLocation">
				<template v-slot:decoration>
					<view class="decoration"></view>
				</template>
				<map class="map" :latitude="latitude" :longitude="longitude"
				 layer-style="1" :markers="covers"></map>
			</uni-section>
			<uni-section :title="show.name">
				<template v-slot:decoration>
					<view class="decoration"></view>
				</template>

				<view class="cards">
					<view class="card" v-for="(item ,index) in this.data.imgs " :key="index">
						<image class="card_img" :src="item" mode=""></image>
						<view class="title">
							<view class="decoration">
							</view>
							<text style="font-size: 13px;color: #616161">厨房㎡</text>
							<view class="decoration">
							</view>
						</view>
					</view>
				</view>
			</uni-section>
			<button type="primary" class="appointment">确定预约</button>
		</view>
	</view>
</template>

<script>
	import request from "@/myutil/my.js"
	export default {
		data() {
			return {
				clients: {
					name: "案例信息",
					listContent: [{
							name: "风格",
							content: "湖南省长沙市天心区新开铺路785号 梦想越秀·江悦和鸣"
						},
						{
							name: "户型",
							content: "88户"
						},
						{
							name: "已签约",
							content: "44户"
						}
					]
				},
				location: "地理位置",
				show: {
					name: "案例展示",
					showList: [{
							name: "书房",
							imgUrl: "/static/Mask group_3.png"
						},
						{
							name: "客厅",
							imgUrl: "/static/Mask group_4.png"
						}
					]
				},
				latitude: 28.107713813889387,
				longitude: 112.96185187776567,
				covers: [{
					id: 1,
					title: 'map',
					width: 30,
					height: 30,
					latitude: 28.107713813889387,
					longitude: 112.96185187776567,
					iconPath: '/static/icon.png'
				}],
				id: 0,
				data: {}
			};
		},
		created() {
			const {
				id
			} = this.$route.query;
			this.id = id;
			console.log(id);
			this.getmessage()
		},
		methods: {
			onLocation() {
				uni.getLocation({
					type: "wgs84",
					success: (res) => {
						uni.chooseLocation({
							latitude: res.latitude,
							longitude: res.longitude,
							success: (res) => {
								console.log(res);
								this.clients.listContent[0].content = res.address + res.name;
								this.longitude = res.longitude;
								this.latitude = res.latitude;
								this.covers[0].longitude = res.longitude
								this.covers[0].latitude = res.latitude
							}
						})
					},
				})
			},

			async getmessage() {
				try {
					const response = await request.post(
						"https://baiyi.kent.work/api/v1/system/getWxComboDetail", {
							id: this.id,
						}
					);
					console.log(response.data);
					this.data = response.data;
				} catch (error) {
					console.error(error);
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	$uni-success: #18bc37 !default;

	page {
		margin: 0;
		padding: 0;
	}

	.content {
		width: 100vw;

		.banner {
			width: 100%;
			position: relative;

			image {
				width: 100%;
			}

			.mask {
				width: 100%;
				height: 62rpx;
				line-height: 62rpx;
				background: rgba(0, 0, 0, .5);
				color: #fff;
				position: absolute;
				bottom: 0;
				text-align: center;
			}
		}

		.index_section {


			.cards {
				width: 100vw;
				margin-top: 1.5vh;
				display: flex;
				flex-direction: column;
				align-items: center;

				.card {
					width: 90vw;
					background-color: #ffffff;
					margin-top: 1.5vh;
					border-radius: 15rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					align-items: center;


					.card_img {
						width: 90vw;
						height: 21vh;
						border-radius: 15rpx 15rpx 0 0;
					}

					.title {
						width: 50vw;
						height: 3.5vh;
						display: flex;
						align-items: center;
						justify-content: center;
						font-weight: 600;

						.decoration {
							width: 35rpx;
							height: 4rpx;
							background-color: #a7d2a4;
							margin: 10rpx;
							border-radius: 10rpx;
						}
					}
				}

			}
			.show_column {
				width: 100vw;

				image {
					width: 90%;
					margin-left: 5%;
				}

				.title {
					width: 100vw;
					text-align: center;
					position: relative;

					.mask {
						width: 100rpx;
						height: 2rpx;
						background: green;
						margin: 0 auto;
						transform: translateY(-38rpx);
					}

					.txt {
						width: 60rpx;
						display: inline-block;
						background-color: #fff;
						height: 70rpx;
						line-height: 70rpx;
					}
				}
			}

			.item_column {
				margin: 0 30rpx;
				display: flex;
				flex-direction: row;

				.item_name {
					width: 100rpx;
					margin-right: 30rpx;
				}

				.item_content {}
			}

			.decoration {
				width: 3px;
				height: 16px;
				margin-right: 4px;
				border-radius: 3px;
				background-color: $uni-success;
			}
		}

		.location_choose {
			width: 100%;
			height: 44px;
			line-height: 44px;
			display: flex;
			justify-content: space-between;
			color: #333;
		}
		.v-slot-image{
			width: 30rpx;
			height: 30rpx;
		}
		.appointment{
			width: 50vw;
			background-color: #18bc37; 
			margin-top: 20rpx
		}
		.map{
			width: 100%;
			height: 300rpx;
		}
	}
</style>
